package com.hw.common.enums;

/**
 * 角色枚举
 */
public enum RoleEnums{
    SUPER_ADMIN(9999, "super admin"),
    ADMIN(5555, "admin"),
    OPERATOR(1111, "operator");

    /**
     * 类型
     */
    private Integer code;

    /**
     * 描述
     */
    private String desc;

    RoleEnums(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 根据code返回枚举对象
     *
     * @param code
     * @return
     */
    public static RoleEnums getEnumByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (RoleEnums roleEnums : RoleEnums.values()) {
            if (roleEnums.getCode().intValue() == code.intValue()) {
                return roleEnums;
            }
        }
        return null;
    }
    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
